package com.redis.data.seckillshopping.controller;

import com.redis.data.seckillshopping.common.Result;
import com.redis.data.seckillshopping.entity.Goods;
import com.redis.data.seckillshopping.service.GoodsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.sql.Date;

/**
 * @author 哲思小辉
 * @version 1.0.0
 * @ClassName GoodsController.java
 * @Description 商品控制类
 * @Param
 * @createTime 2020年03月25日 20:35:00
 */
@Component
@RestController
@RequestMapping("goods")
@Api(value = "商品控制类", tags = "商品控制类")
public class GoodsController {
    /**
     * 服务对象
     */
    @Autowired
    private GoodsService goodsService;

    @PostMapping("addGoods")
    @ApiOperation(value = "新增商品", notes = "新增商品")
    public Result<Goods> addGoods(@RequestBody Goods goods) {
        goods = this.goodsService.insert(goods);
        return Result.success(goods);
    }

    @PostMapping("getGoods")
    @ApiOperation(value = "获取商品", notes = "获取商品")
    public Result<Goods> addGoods(Integer goodsId) {
        Goods goods = this.goodsService.queryById(goodsId);
        return Result.success(goods);
    }
}